package org.ucas.faker.web.fetcher.cond;

import org.ucas.faker.web.fetcher.meta.ColumnField;
import org.ucas.faker.web.fetcher.meta.Table;

import java.io.Serializable;

public abstract class FetchCond implements Serializable {
  public abstract String sql();

  public FetchCond and(FetchCond cond) {
    if(cond == null) return this;

    if(cond instanceof AndCond) {
      cond.and(this);
      return cond;
    }
    AndCond res = new AndCond();
    res.add(this);
    res.add(cond);
    return res;
  }

  @Override
  public int hashCode() {
    String sql = sql();
    return sql == null? 0 : sql.hashCode();
  }

  public abstract void replace(Table src, Table dst);
}
